/**
 * Created by Terry on 15-4-30.
 */
var MessageSender = (function () {
    function f() {

    }

    f.send = function (childId, data) {
        var ch = document.getElementById(childId);

        if (ch) {
            ch.contentWindow.postMessage(data, "*");
        } else {
            console.log("no child id ", childId);
        }
    };

    f.sendToParent = function (data) {
        if (window.parent) {
            window.parent.postMessage(data, "*");
        } else {
            console.log("on parent");
        }
    };

    return f;
})();

var MessageReceiver = (function () {
    function f() {

    }

    f.receiveMessage = function (callback) {
        window.addEventListener("message", callback);
    };

    return f;
})();